﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ThanhTu.GNC.Media.KQXS.DataAccess.BL;
using ThanhTu.GNC.Media.KQXS.DataAccess.DO;

namespace GNCMedia.KQXS.Admin
{
    public partial class UpdateTintuc : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            int newsid = Convert.ToInt32(Request.QueryString["ID"]);
            BreakingNewsBL br = new BreakingNewsBL();
            BreakingNewsDO brDO = new BreakingNewsDO();
            brDO = br.getbyAwards(newsid);
            txt_content.Text = brDO.Content;
        }

        protected void btn_addNewData_Click1(object sender, EventArgs e)
        {
            try
            {
                int newsid = Convert.ToInt32(Request.QueryString["ID"]);

                BreakingNewsBL br = new BreakingNewsBL();
                BreakingNewsDO brDO = new BreakingNewsDO();
                brDO.Newid = newsid;
                brDO.Groupnews = drl_muctin.SelectedIndex;
                brDO.Image = "../Admin/images/" + file_upload.FileName.ToString();
                brDO.Content = txt_content.Text;
                int checkUpdate = br.UpdateNews(brDO);
                if (checkUpdate > 0)
                {
                    lBLtHONGBAO.ForeColor = System.Drawing.Color.Blue;
                    lBLtHONGBAO.Text = "Chỉnh sửa thành công";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "javascript:alert('chỉnh sửa Thành công);", true);
                }
                else
                {
                    lBLtHONGBAO.ForeColor = System.Drawing.Color.Red;
                    lBLtHONGBAO.Text = "Thêm mới thành công";
                    Page.ClientScript.RegisterStartupScript(this.GetType(), "ShowStatus", "javascript:alert('LỖI,XIN VUI LÒNG THỬ LẠI);", true);
                }


            }
            catch (Exception ex)
            {
                Response.Write("lỗi cập nhật tin tức" + ex);
            }
            finally
            {

            }
        }

        protected void lbtnLogout_Click1(object sender, EventArgs e)
        {


        }
    }
}